<template>
    <div>
        <Button @click="back">返回</Button>
        <wl-excel-import
                :interface-url="'/api/ac/jcar/excelService/saveHolidayname'"
                :template-url="'http://house-manager.oss-cn-qingdao.aliyuncs.com/fuel-card/%E8%8A%82%E5%81%87%E6%97%A5%E6%97%A5%E6%9C%9F%E8%A1%A8.xlsx'"
                :validate-data="validateData"
                :handle-data="handleData"
                :fail-column="failColumn"
                :header-field="headerField"
        ></wl-excel-import>
    </div>
</template>

<script>

export default {

  name: 'excel',

  data () {
    return {
      failColumn: [
        {
          title: '节假日时间',
          key: 'date_time'
        },
        {
          title: '节假日名称',
          key: 'holiday_name'
        }
      ],
      headerField: [
        { title: '节假日时间', field: 'date_time', minWidth: 300 },
        { title: '节假日名称', field: 'holiday_name', minWidth: 300 }
      ]
    }
  },

  props: {

  },

  components: {

  },

  computed: {

  },

  methods: {
    async init () {

    },
    handleData (item) {
      item.date_time = item.date_time.replace(/\//g, '-')
      console.log(item, 'item')
    },
    validateData (item, error, tName) {
      // 校验节假日时间
      if (!item.date_time) {
        item.date_time = ' （节假日时间不能为空）'
        item.cellClassName.date_time = tName
        error = true
      }
      return error
    },
    back () {
      this.$router.push({
        name: 'holidayd'
      })
    }
  },

  watch: {

  },

  mounted () {
    this.init()
  }

}
</script>

<style scoped>

</style>
